package com.example.backend.service;


import com.example.backend.entity.Sign;
import com.example.backend.mapper.SignMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SignService {

    private SignMapper signMapper;

    @Autowired
    public SignService(SignMapper signMapper){
        this.signMapper = signMapper;
    }

    public boolean insertSign(@Param("userId") int userId, @Param("lastDate") String lastDate){
        int sign = signMapper.insertSign(userId,lastDate);
        if(sign == 0)
            return false;
        else
            return true;
    }

    public boolean updateSign(@Param("userid") int userid,@Param("lastDate") String lastDate){
        int sign = signMapper.updateSign(userid,lastDate);
        if(sign == 0)
            return false;
        else
            return true;
    }

    public boolean ifSign(@Param("userId") int userId){
        List<Sign> sign = signMapper.ifSign(userId);
        if(sign.size() == 0)
            return  false;
        else
            return true;
    }
}
